package com.woniu.cq.springboot_mybatisplus_shiro.dao;


import com.woniu.cq.springboot_mybatisplus_shiro.entity.User;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
 * @Author: Klaus
 * @Date: 2020/9/2 20:18
 */
public interface AuthMapper {
    //user_id,user_account,user_password
    @Select("select user_id,user_account,user_password from pre_user where user_account = #{account}")
    User findUserByAccount(String account);

    @Select("select r.role_name from pre_user u " +
            "LEFT JOIN pre_user_role ur on u.user_id = ur.user_id " +
            "LEFT JOIN pre_role r on ur.role_id = r.role_id " +
            "where u.user_id = #{userId}")
    Set<String> findRolesById(int userId);

    @Select("select p.pre_name from pre_user u " +
            "LEFT JOIN pre_user_role ur on u.user_id = ur.user_id " +
            "LEFT JOIN pre_role_pre rp on ur.role_id = rp.role_id " +
            "LEFT JOIN pre_pre p on rp.pre_id = p.pre_id " +
            "where u.user_id= #{userId}")
    Set<String> findPreById(int userId);
}
